home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bprojectplugin.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  4.7 KB  |  162 lines

  1. /* 
  2.  *
  3.  * $Id: k3bprojectplugin.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2004 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16. #ifndef _K3B_PROJECT_PLUGIN_H_
  17. #define _K3B_PROJECT_PLUGIN_H_
  18.  
  19. #include <k3bplugin.h>
  20. #include <qstring.h>
  21. #include "k3b_export.h"
  22. class K3bDoc;
  23.  
  24. /**
  25.  * In case your plugin provides a GUI it is recommended to use the 
  26.  * K3bProjectPluginGUIBase interface. That way K3b can embed the GUI into 
  27.  * a fancy dialog which fits the overall look.
  28.  *
  29.  * This is not derived from QWidget to make it possible to inherit
  30.  * from other QWidget derivates.
  31.  */
  32. class K3bProjectPluginGUIBase
  33. {
  34.  public:
  35.   K3bProjectPluginGUIBase() {}
  36.   virtual ~K3bProjectPluginGUIBase() {}
  37.  
  38.   virtual QWidget* qWidget() = 0;
  39.  
  40.   /**
  41.    * Title used for the GUI
  42.    */
  43.   virtual QString title() const = 0;
  44.   virtual QString subTitle() const { return QString::null; }
  45.  
  46.   virtual void readSettings( KConfigBase* ) {}
  47.   virtual void saveSettings( KConfigBase* ) {}
  48.  
  49.   /**
  50.    * Load system defaults for the GUI
  51.    */
  52.   virtual void loadDefaults() {}
  53.  
  54.   /**
  55.    * Start the plugin. This method should do the actual work.
  56.    */
  57.   virtual void activate() = 0;
  58. };
  59.  
  60.  
  61. /**
  62.  * A K3bProjectPlugin is supposed to modify a k3b project in some way or
  63.  * create additional data based on the project.
  64.  *
  65.  * Reimplement createGUI or activate and use setText, setToolTip, setWhatsThis, and setIcon
  66.  * to specify the gui elements used when presenting the plugin to the user.
  67.  */
  68. class LIBK3B_EXPORT K3bProjectPlugin : public K3bPlugin
  69. {
  70.   Q_OBJECT
  71.  
  72.  public:
  73.   /**
  74.    * @param type The type of the plugin
  75.    * @param gui If true the plugin is supposed to provide a widget via @p createGUI(). In that case
  76.    *            @p activate() will not be used. A plugin has a GUI if it's functionality is started 
  77.    *            by some user input.
  78.    */
  79.   K3bProjectPlugin( int type, bool gui = false, QObject* parent = 0, const char* name = 0 )
  80.   : K3bPlugin( parent, name ),
  81.     m_type(type),
  82.     m_hasGUI(gui) {
  83.   }
  84.  
  85.   virtual ~K3bProjectPlugin() {
  86.   }
  87.  
  88.   // TODO: move this to K3bDoc?
  89.   enum Type {
  90.     AUDIO_CD = 0x1,
  91.     DATA_CD = 0x2,
  92.     MIXED_CD = 0x4,
  93.     VIDEO_CD = 0x8,
  94.     MOVIX_CD = 0x10,
  95.     DATA_DVD = 0x20,
  96.     VIDEO_DVD = 0x40,
  97.     MOVIX_DVD = 0x80,
  98.     DATA_PROJECTS = DATA_CD|DATA_DVD,
  99.     MOVIX_PROJECTS = MOVIX_CD|MOVIX_DVD
  100.   };
  101.  
  102.   // TODO: maybe we should use something like "ProjectPlugin/AudioCD" based on the type?
  103.   QString group() const { return "ProjectPlugin"; }
  104.  
  105.   /**
  106.    * audio, data, videocd, or videodvd
  107.    * Needs to return a proper type. The default implementation returns the type specified
  108.    * in the constructor.
  109.    */
  110.   virtual int type() const { return m_type; }
  111.  
  112.   /**
  113.    * Text used for menu entries and the like.
  114.    */
  115.   const QString& text() const { return m_text; }
  116.   const QString& toolTip() const { return m_toolTip; }
  117.   const QString& whatsThis() const { return m_whatsThis; }
  118.   const QString& icon() const { return m_icon; }
  119.  
  120.   bool hasGUI() const { return m_hasGUI; }
  121.  
  122.   /**
  123.    * Create the GUI which provides the features for the plugin.
  124.    * This only needs to be implemented in case hasGUI returns true.
  125.    * The returned object has to be a QWidget based class.
  126.    *
  127.    * @param doc based on the type returned by the factory
  128.    *            this will be the doc to work on. It should
  129.    *            be dynamically casted to the needed project type.
  130.    */
  131.   virtual K3bProjectPluginGUIBase* createGUI( K3bDoc* doc, QWidget* = 0, const char* = 0 ) { Q_UNUSED(doc); return 0; }
  132.  
  133.   /**
  134.    * This is where the action happens.
  135.    * There is no need to implement this in case hasGUI returns true.
  136.    *
  137.    * @param doc based on the type returned by the factory
  138.    *            this will be the doc to work on. It should
  139.    *            be dynamically casted to the needed project type.
  140.    *
  141.    * @param parent the parent widget to be used for things like progress dialogs.
  142.    */
  143.   virtual void activate( K3bDoc* doc, QWidget* parent ) { Q_UNUSED(doc); Q_UNUSED(parent); }
  144.  
  145.  protected:
  146.   void setText( const QString& s ) { m_text = s; }
  147.   void setToolTip( const QString& s ) { m_toolTip = s; }
  148.   void setWhatsThis( const QString& s ) { m_whatsThis = s; }
  149.   void setIcon( const QString& s ) { m_icon = s; }
  150.  
  151.  private:
  152.   int m_type;
  153.   bool m_hasGUI;
  154.   QString m_text;
  155.   QString m_toolTip;
  156.   QString m_whatsThis;
  157.   QString m_icon;
  158. };
  159.  
  160.  
  161. #endif
  162.